﻿using System;
using System.Collections.Generic;
using System.Text;
using Model;
namespace Hotfix
{
    [MessageHandler(AppType.Realm)]
    public class RoomTalkHandle : AMHandler<TalkRoom>
    {
        protected override void Run(Session session, TalkRoom message)
        {
            try
            {
                Room room = Game.Scene.GetComponent<RoomManagerComponent>().GetRoom(message.RoomName);
                if (room == null) return;
                Log.Debug($"RoomMessage:{message.MessageInfo} Number:{room.GetComponent<RoomSessionComponent>().SessionIds.Count}");
                foreach (var a in room.GetComponent<RoomSessionComponent>().SessionIds)
                {
                    Game.Scene.GetComponent<ActorProxyComponent>().Get(a).Send(new Actor_Test() { Info = message.MessageInfo });
                    //a.Send(new Actor_Test() { Info = message.MessageInfo });
                }
            }
            catch (Exception e)
            {
                Log.Debug(e.ToString());
            }
        }
    }
}
